package com.deuwise.system.entity;

import com.deuwise.common.utils.BitStatesUtils;
import lombok.Data;

/**
 * Copyright
 *
 * @author chenwenchao
 * @date 2019/3/19
 * Description:
 * 密码配置类
 */
@Data
public class PassWordConfig extends ConfigDo {
    /**
     * 判断是否设置密码检测
     * @return
     */
    public boolean getIsCheckPassWord() {
        return BitStatesUtils.hasState(Long.parseLong(this.getValue()),
                BitStatesUtils.USE_PASSWORD_CHECK);
    }

    /**
     * 判断是否包含密码
     * @return
     */
    public boolean getIncludeNum() {
        return BitStatesUtils.hasState(Long.parseLong(this.getValue()),
                BitStatesUtils.INCLUDE_NUM);
    }
    /**
     * 判断是否包含小写字母
     * @return
     */
    public boolean getIncludeLowerCase() {
        return BitStatesUtils.hasState(Long.parseLong(this.getValue()),
                BitStatesUtils.INCLUDE_LOWERCASE);
    }

    /**
     * 判断是否包含大写字母
     * @return
     */
    public boolean getIncludeUpperCase() {
        return BitStatesUtils.hasState(Long.parseLong(this.getValue()),
                BitStatesUtils.INCLUDE_UPPERCASE);
    }
    /**
     * 判断是否包含大写字母
     * @return
     */
    public boolean getIncludeSpecial() {
        return BitStatesUtils.hasState(Long.parseLong(this.getValue()),
                BitStatesUtils.INCLUDE_SPECIAL);
    }

    /**
     * 判断是否包含大写字母
     * @return
     */
    public boolean getOverDue() {
        return BitStatesUtils.hasState(Long.parseLong(this.getValue()),
                BitStatesUtils.OVER_DUE);
    }

    /**
     *添加绑定的状态码
     * @param state
     */
    public void addState(Long state) {
        this.setValue(String.valueOf(BitStatesUtils.addState(Long.parseLong(this.getValue()), state)));
    }

    /**
     *移除状态码
     * @param state
     */
    public void  removeState(Long state) {
        this.setValue(String.valueOf(BitStatesUtils.removeState(Long.parseLong(this.getValue()), state)));
    }

}
